package authentication

import (
	"crypto/x509"
	"encoding/pem"
	"fmt"
	"io/ioutil"
)


func ReadCertificate(filename string) (*x509.Certificate, error) {
	pemBytes, err := ioutil.ReadFile(filename)
	if err != nil {
		return nil, fmt.Errorf("打开CA证书失败: %v", err)
	}
	block, _ := pem.Decode(pemBytes)
	return x509.ParseCertificate(block.Bytes)
}

func ReadKeyFile(filename string) (interface{}, error) {
	pemBytes, err := ioutil.ReadFile(filename)
	if err != nil {
		return nil, fmt.Errorf("打开CA证书失败: %v", err)
	}
	block, _ := pem.Decode(pemBytes)
	return x509.ParsePKCS8PrivateKey(block.Bytes)
}

